<template>
    <div class="box">
        <div class="null-page" v-show="yes"></div>
		<el-card class="box-card member-coupon">

        <div class="my-account">
            <div class="detail">
                <el-table :data="accountList" border>
                     <el-table-column label="头像" width="80">
                        <template slot-scope="scope" style="height:30px;">
                            <img v-if="!scope.row.headimg" :src="circleUrl" alt="" style="width:30px;height:30px;padding-left:15px;"> 
                            <img v-else :src="scope.row.headimg" alt="" style="width:30px;height:30px;padding-left:15px;">
                        </template>
                    </el-table-column>
                    <el-table-column prop="username" label="账号"></el-table-column>
                    <el-table-column prop="company_name" label="姓名"></el-table-column>
                    <el-table-column prop="invite_name" label="邀请人"></el-table-column>
                    <el-table-column  :formatter="dateFormat" label="邀请时间">
                           <template slot-scope="scope">
                                  <span> {{ $util.timeStampTurnTime(scope.row.reg_time)}} </span>   
                            </template>
                    </el-table-column>
                </el-table>
            </div>
            <div class="pager">
                <el-pagination background :pager-count="5" :total="total" prev-text="上一页" next-text="下一页" :current-page.sync="account.page" :page-size.sync="account.page_size" @size-change="handlePageSizeChange" @current-change="handleCurrentPageChange" hide-on-single-page></el-pagination>
            </div>
        </div>
        </el-card>
    </div>
</template>

<script>
import moment from 'moment'
import { getChildEnterpriseUserList } from "@/api/member/subordinate_company"
export default {
    name: "zijiguanli",

    data: () => {
        return {
            account: {
                page: 1,
                page_size: 10
            },
            circleUrl: "http://localhost/subject_baishangwanqihui/app/admin/view/public/img/default_headimg.png",
            accountList: [],
            total: 0,
            integer: 0,
            decimal: 0,
            yes: true
        }
    },
    created() {
        this.getcompany()
    },
    mounted() {
        let self = this
        setTimeout(function () {
            self.yes = false
        }, 300)
    },
    methods: {
        getcompany() {
            getChildEnterpriseUserList({
                page_size: this.account.page_size,
                page: this.account.page,
                account_type: "balance"
            })
                .then((res) => {
                    if (res.code == 0 && res.data) {
                        this.accountList = res.data.list
                        this.total = res.data.count
                        this.accountList.forEach((item) => {
                            item.time = this.$util.timeStampTurnTime(item.create_time)
                        })
                    }
                })
                .catch((err) => {
                    this.$message.error(err.message)
                })
        },

        handlePageSizeChange(num) {
            this.account.page_size = num
            this.getcompany()
        },
        handleCurrentPageChange(page) {
            this.account.page = page
            this.getcompany()
        },
        dateFormat: function (row, column) {
            var date = row[column.property]
            if (date == undefined) {
                return ""
            }
            var moment = require("moment")
            return moment(date).format("YYYY-MM-DD HH:mm:ss")
        }
    }
}
</script>
<style lang="scss" scoped>
.box {
    width: 100%;
    position: relative;
}

.null-page {
    width: 100%;
    height: 730px;
    background-color: #ffffff;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 9;
}
</style>
